package com.example.myapplication1;

import androidx.appcompat.app.AppCompatActivity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

public class RegActivity extends AppCompatActivity {
    private LinearLayout linearLayout;
    private TextView tvUsername;
    private EditText etUsername;
    private TextView tvPassword;
    private EditText etPassword;
    private TextView tvRegage;
    private EditText etRegage;
    private TextView tvReggender;
    private EditText etReggender;
    private Button btnLogin;
    private Button btnReturn;



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_reg);
        linearLayout = (LinearLayout) findViewById(R.id.linearLayout);
        tvUsername = (TextView) findViewById(R.id.tv_username);
        etUsername = (EditText) findViewById(R.id.et_username);
        tvPassword = (TextView) findViewById(R.id.tv_password);
        etPassword = (EditText) findViewById(R.id.et_password);
        tvRegage = (TextView) findViewById(R.id.tv_regage);
        etRegage = (EditText) findViewById(R.id.et_regage);
        tvReggender = (TextView) findViewById(R.id.tv_reggender);
        etReggender = (EditText) findViewById(R.id.et_reggender);
        btnLogin = (Button) findViewById(R.id.btn_login);
        btnReturn = (Button) findViewById(R.id.btn_return);
    }

    public void submit(View view) {
        if(etUsername.getText().toString().length()>4){
            Intent intent = new Intent(this,MainActivity.class);
            intent.putExtra("username",etUsername.getText().toString());
            intent.putExtra("password",etPassword.getText().toString());
            intent.putExtra("gender",etReggender.getText().toString());
            intent.putExtra("age",etRegage.getText().toString());
            setResult(Activity.RESULT_OK,intent);
            finish();

        }else {
            Toast.makeText(this,"请使用合法的用户名和密码",Toast.LENGTH_SHORT).show();
        }
    }

    public void cancel(View view) {
        setResult(Activity.RESULT_CANCELED);
        finish();
    }
}